package com.onetech.adrewards.free.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.google.analytics.tracking.android.EasyTracker;
import com.onetech.adrewards.free.R;
import com.onetech.adrewards.free.activities.CommonWebViewInfoActivity;
import com.onetech.adrewards.free.activities.FeedbackActivity;
import com.onetech.adrewards.free.config.AppConfig;

public class FeedbackOptionFragment extends BaseFragment {
	private View mFeedBackBtn = null;
	private View mEAQBtn = null;
	private View mAboutPointBtn = null;
	private View mPolicyBtn = null;
	private View mPrivacyBtn = null;
	private View mMenu4Btn = null;
	private String url="";
	private String title="";
	
//	@Override
//	protected void onCreate(Bundle arg0) {
//		super.onCreate(arg0);
//		setMainView(R.layout.group_feed_back_items_layout);
//		setAppTittle(getString(R.string.feedback_title));
//		initView();
//		initListener();
//	}
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if (mView == null) {
			mView = inflater.inflate(R.layout.group_feed_back_items_layout, container,
					false);
			initView();
			initListener();			

		} else {
			((ViewGroup) mView.getParent()).removeView(mView);
		}
		return mView;
	}
	private void initView() {
		mFeedBackBtn = (RelativeLayout) mView.findViewById(R.id.feedbackBtn);
		mEAQBtn = (RelativeLayout) mView.findViewById(R.id.faqBtn);
		mAboutPointBtn = (RelativeLayout) mView.findViewById(R.id.aboutPointBtn);
		mPolicyBtn = (RelativeLayout) mView.findViewById(R.id.policyBtn);
		mPrivacyBtn = (RelativeLayout) mView.findViewById(R.id.privacyBtn);
		mMenu4Btn=(RelativeLayout)mView.findViewById(R.id.menu4);		
	}

	private void initListener() {
		mFeedBackBtn.setOnClickListener(this);
		mEAQBtn.setOnClickListener(this);
		mAboutPointBtn.setOnClickListener(this);
		mPolicyBtn.setOnClickListener(this);
		mPrivacyBtn.setOnClickListener(this);
		mMenu4Btn.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		int id = v.getId();
		switch (id) {
		case R.id.feedbackBtn:
			Intent mIntent=new Intent(getActivity(), FeedbackActivity.class);
			startActivity(mIntent);
			return;			
		case R.id.faqBtn:
			url= AppConfig.URLRequestApi.GET_STATIC_PAGE + "1";	
			title=getString(R.string.faq_title);
			break;
		case R.id.aboutPointBtn:
			url = AppConfig.URLRequestApi.GET_STATIC_PAGE + "2";
			title = getString(R.string.about_point_title);
			break;
		case R.id.menu4:
			url = AppConfig.URLRequestApi.GET_STATIC_PAGE + "4";
			title=getString(R.string.menu4_title);
			break;
		case R.id.policyBtn:
			url = AppConfig.URLRequestApi.GET_STATIC_PAGE + "3";
			title = getString(R.string.policy_title);
			break;
		case R.id.privacyBtn:
			url= AppConfig.URLRequestApi.GET_STATIC_PAGE + "5";
			title=getString(R.string.privacy_title);
			break;

		default:
			super.onClick(v);
			return;
		}
		Intent intent=new Intent(getActivity(), CommonWebViewInfoActivity.class);
		intent.putExtra("URL", url);
		intent.putExtra("ViewTitle", title);
		startActivity(intent);
	}
	@Override
	public void onResume() {
		super.onResume();
		getBaseNewActivity().getUserInfo();
	}
	@Override
	public void onStart() {
	    super.onStart();
	   // The rest of your onStart() code.
	    try {
	    	EasyTracker.getInstance(getActivity()).activityStart(getActivity());  // Add this method.
		} catch (Exception e) {			
		}
	  }

	  @Override
	  public void onStop() {
	    super.onStop();
	    // The rest of your onStop() code.
	    try {
	    	EasyTracker.getInstance(getActivity()).activityStop(getActivity());  // Add this method.
		} catch (Exception e) {
		}
	  }
}
